﻿using System.Windows.Data;

namespace Kaesoft.Hospedaje.Common
{
    /// <summary>
    /// Remover saltos de linea en strings para uso en grids
    /// </summary>
    public class StringGridConverter : IValueConverter
    {
        #region IValueConverter Members
        /// <summary>
        /// Remover saltos de linea
        /// </summary>
        /// <param name="value">Cadena</param>
        /// <param name="targetType">String</param>
        /// <param name="parameter">Parametro de conversion (no se usa)</param>
        /// <param name="culture">Cultura actual</param>
        /// <returns>String sin saltos de linea</returns>
        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                string entryString = value.ToString();
                return entryString.Replace("\r\n", "").Replace("\n", "").Replace("\r", "");
            }
            return string.Empty;
        }

        /// <summary>
        /// Sin implementación
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns>null</returns>
        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }
        #endregion
    }
}